package org.shunya.duplicatefileperquisitor.gui;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import org.shunya.duplicatefileperquisitor.model.FileTypeExtensions;

import java.net.URL;
import java.util.ResourceBundle;

public class FileMaskDialogController extends AnchorPane implements Initializable {
    @FXML TextField fileMaskTxtFld;
    @FXML TextField descriptionTxtFld;
    @FXML Button saveBtn;
    @FXML Button cancelBtn;
    private FileTypeExtensions fileTypesTxt;
    private Stage stage;

    public void onSaveBtnActionEvent() {
        fileTypesTxt.setSelected(true);
        fileTypesTxt.setExtensions(fileMaskTxtFld.getText());
        fileTypesTxt.setDescription(descriptionTxtFld.getText());
        stage.close();
    }

    public void onCancelBtnActionEvent() {
        stage.close();
    }

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    public void setFileTypesTxt(FileTypeExtensions fileTypesTxt) {
        this.fileTypesTxt = fileTypesTxt;
    }

    public void setStage(Stage stage) {
        this.stage = stage;
    }
}
